React newsletter


Posted by mijouhsieh on 2023-12-24

codesandbox
練習來源: https://rudy.capital/en/home/#faq
react-form-rudy-newsletter.png

應用 useState, useRef, forwardRef
React useRef

子元件 使用 forwardRef,可讓父元件獲得 子元件的 ref,讓父元件能訪問和操作子元件。

將元件都寫在Form.js中。import forward函式

import React, { useState, forwardRef } from "react";
import { useRef } from "react";
import styles from "./Form.module.css";

子元件

react-form-inputName.png

react-form-inputEmail.png

父元件

react-form.png


再實作相關功能

CHATGTP


#useRef #forwardRef #useState #Reacr form #newsletter







Related Posts

後端軟體工程工具箱:資料庫/SQL/ORM篇

後端軟體工程工具箱:資料庫/SQL/ORM篇

一次搞懂 var、let、const 三種變數

一次搞懂 var、let、const 三種變數

內嵌 youtube 的廣告

內嵌 youtube 的廣告


Comments